<template>
    <div>
        <h1>登录</h1>
        <table class="table">
            <tbody>
                <tr>
                    <td>用户名</td>
                    <td><input type="text" v-model="data.Name"></td>
                </tr>
                <tr>
                    <td>密码</td>
                    <td><input type="password" v-model="data.Pass"></td>
                </tr>
                <tr>
                    <td></td>
                    <td><input type="button" value="登录" @click="deng"></td>
                </tr>
            </tbody>
        </table>
    </div>
</template>

<script setup lang="ts">
import { ref } from 'vue';
import axios from 'axios';
import { useRouter } from 'vue-router';

const data = ref({
    "Id": 0,
  "Name": "",
  "Pass": ""
})

const router= useRouter()
const deng=()=>{
    axios.get('https://localhost:7248/api/Login/Deng',{params:data.value}).then(res=>{
        if(res.data.Id==-1){
            alert('用户不存在')
            return
        }
        else{
            if(res.data.Id==-2){
                alert('密码错误');
                return
            }
            alert('登陆成功')
            router.push({path:"/Show"})
        }
    })
}




</script>

<style scoped>

</style>